<!DOCTYPE HTML>
<html lang="zh-cn" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE" />
        <title>domplate() 函数 | Domplate 文档</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.0.1">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" href="../gitbook/prettify/prettify.css" />
        
    
    
    <link rel="next" href="../jsapi/ctrl.html" />
    
    
    <link rel="prev" href="../jsapi/index.html" />
    

        
    </head>
    <body>
        
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
    

        
    <div class="book" data-level="3.1" data-basepath=".." data-revision="Tue May 19 2015 01:42:16 GMT+0800 (CST)">
    

<div class="book-summary">
    <div class="book-search">
        <input type="text" placeholder="输入并搜索" class="form-control" />
    </div>
    <ul class="summary">
        
        
        
        

        

        
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                        <i class="fa fa-check"></i>
                        
                        介绍
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="usage/index.html">
            
                
                    <a href="../usage/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        用法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="features/index.html">
            
                
                    <a href="../features/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        特性
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="features/expression.html">
            
                
                    <a href="../features/expression.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        表达式
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="features/init.html">
            
                
                    <a href="../features/init.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        数据初始化属性
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="features/flow.html">
            
                
                    <a href="../features/flow.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        流程控制属性
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="features/show.html">
            
                
                    <a href="../features/show.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.1.</b>
                        
                        show
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="features/repeat.html">
            
                
                    <a href="../features/repeat.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.2.</b>
                        
                        repeat
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="features/switch.html">
            
                
                    <a href="../features/switch.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.3.</b>
                        
                        switch
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="features/event.html">
            
                
                    <a href="../features/event.html">
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        事件属性
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="jsapi/index.html">
            
                
                    <a href="../jsapi/index.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        JS 接口
                    </a>
                
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="3.1" data-path="jsapi/domplate.html">
            
                
                    <a href="../jsapi/domplate.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        domplate() 函数
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="jsapi/ctrl.html">
            
                
                    <a href="../jsapi/ctrl.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        ctrl 对象
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="jsapi/data.html">
            
                
                    <a href="../jsapi/data.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        ctrl.data 属性
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="jsapi/load.html">
            
                
                    <a href="../jsapi/load.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        ctrl.load() 方法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="jsapi/methods.html">
            
                
                    <a href="../jsapi/methods.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        ctrl.methods() 方法
                    </a>
                
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="jsapi/update.html">
            
                
                    <a href="../jsapi/update.html">
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        ctrl.update() 方法
                    </a>
                
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="about/me.html">
            
                
                    <a href="../about/me.html">
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        其它
                    </a>
                
            
            
        </li>
    


        
        <li class="divider"></li>
        <li>
            <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                本书使用 GitBook 发布
            </a>
        </li>
        
    </ul>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="目录"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="搜索"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="字体设置"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">衬线体</button>
        <button type="button" data-font="1" class="button">无衬线体</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">白色</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">棕褐色</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">夜间</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="分享"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    分享到 Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    分享到 Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    分享到 Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    分享到 Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    分享到 Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >Domplate 文档</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="domplate-%E5%87%BD%E6%95%B0">domplate() &#x51FD;&#x6570;</h1>
<pre><code class="prettyprint lang-javascript">var ctrl = &#x200C;domplate&#x200D;( element );`
</code></pre>
<p>&#x5C06;&#x9875;&#x9762;&#x4E2D;&#x5DF2;&#x5B58;&#x5728;&#x7684; element &#x5143;&#x7D20;&#x4F5C;&#x4E3A; dompalte &#x6A21;&#x677F;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x5E76;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x63A7;&#x5236;&#x5668;&#x5BF9;&#x8C61; ctrl&#x3002;</p>
<blockquote>
<p><code>element</code> &#x53C2;&#x6570;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A; dom &#x5BF9;&#x8C61;&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;domplate &#x5185;&#x90E8;&#x4EE5; <code>document.querySelector( element )</code> &#x5C06;&#x5176;&#x8F6C;&#x5316;&#x6210;&#x4E00;&#x4E2A; dom &#x5BF9;&#x8C61;&#x3002;</p>
</blockquote>
<p>&#x8C03;&#x7528; dompalte &#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5C06;&#x5BF9;&#x6307;&#x5B9A;&#x7684; dom &#x5143;&#x7D20;&#x8FDB;&#x884C;&#x89E3;&#x6790;&#xFF0C;&#x5982;&#x679C;&#x8BE5; dom &#x5143;&#x7D20;&#x4EE5;&#x53CA;&#x5176;&#x4EFB;&#x4F55;&#x7236;&#x7EA7; dom &#x5143;&#x7D20;&#x672A;&#x88AB; domplate &#x89E3;&#x6790;&#x8FC7;&#xFF0C;&#x5219;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A;&#x63A7;&#x5236;&#x5668;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x5C06;&#x8BE5;&#x63A7;&#x5236;&#x5668;&#x5BF9;&#x8C61;&#x8FD4;&#x56DE;&#xFF0C;&#x4E0A;&#x8FF0;&#x7684;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;<code>ctrl</code> &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x63A7;&#x5236;&#x5668;&#x5BF9;&#x8C61;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; ctrl &#x6765;&#x63A7;&#x5236; element &#x89C6;&#x56FE;&#x3002;</p>
<blockquote>
<p>&#x521D;&#x59CB;&#x5316;&#x65F6;&#x4F20;&#x5165;&#x7684; element &#x5BF9;&#x8C61;&#xFF0C;&#x79F0;&#x4E3A; ctrl &#x63A7;&#x5236;&#x5668;&#x7684;&#x6839;&#x8282;&#x70B9;&#x3002;</p>
</blockquote>
<p>&#x800C;&#x5982;&#x679C;&#x8C03;&#x7528; domplate &#x51FD;&#x6570;&#x65F6;&#x4F20;&#x5165;&#x7684; element &#x5DF2;&#x7ECF;&#x662F;&#x67D0;&#x4E2A;&#x63A7;&#x5236;&#x5668;&#x7684;&#x6839;&#x8282;&#x70B9;&#xFF0C;&#x8FD4;&#x76F4;&#x63A5;&#x8FD4;&#x56DE;&#x6240;&#x5728;&#x7684;&#x63A7;&#x5236;&#x5668;&#xFF1B;&#x5982;&#x679C; element &#x4E0D;&#x662F;&#x6839;&#x8282;&#x70B9;&#xFF0C;&#x4F46;&#x5B83;&#x7684;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x7236;&#x8282;&#x70B9;&#x662F;&#x6839;&#x8282;&#x70B9;&#x65F6;&#xFF0C;&#x8FD4;&#x56DE; null&#x3002;</p>
<p>&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x4E0A;&#x5141;&#x8BB8;&#x540C;&#x65F6;&#x5B58;&#x5728;&#x591A;&#x4E2A; domplate &#x5E94;&#x7528;&#xFF0C;&#x8FD9;&#x70B9;&#x5728; <a href="../usage/index.html">&#x7528;&#x6CD5;</a> &#x4E00;&#x8282;&#x4E2D;&#x5DF2;&#x6709;&#x8BF4;&#x660E;&#x3002;</p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../jsapi/index.html" class="navigation navigation-prev " aria-label="Previous page: JS 接口"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../jsapi/ctrl.html" class="navigation navigation-next " aria-label="Next page: ctrl 对象"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app-min.js"></script>
<script src="../gitbook/prettify/prettify.js"></script>
<script src="../common/inject-min.js"></script>

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
